/**
 ******************************************************************************
 * @file    pad.c
 * @author  hyseim software Team
 * @date    26-Mar-2024
 * @brief   
 ******************************************************************************
 * @attention
 * 
 * Copyright (c) 2020 Hyseim. Co., Ltd.
 * All rights reserved.
 * 
 * This software is licensed under terms that can be found in the LICENSE file
 * in the root directory of this software component.
 * If no LICENSE file comes with this software, it is provided AS-IS.
 * 
 ******************************************************************************
 */

#include "pad.h"

void PAD_Init(PADCfg_TypeDef *pad, PAD_Pin pin, uint32_t padConfig)
{
    pad->PAD[pin].CS = (padConfig >> PAD_CMOSMODE_ENABLE) & 0x01;
    pad->PAD[pin].OS = (padConfig >> PAD_OS_ENABLE) & 0x01;
    pad->PAD[pin].OD = (padConfig >> PAD_OD_ENABLE) & 0x01;
    pad->PAD[pin].PU = (padConfig >> PAD_PU_ENABLE) & 0x01;
    pad->PAD[pin].PD = (padConfig >> PAD_PD_ENABLE) & 0x01;
    pad->PAD[pin].DR = (padConfig >> PAD_DR_ENABLE) & 0x01;
    pad->PAD[pin].SR = (padConfig >> PAD_SR_ENABLE) & 0x01;
}

void PAD_SelFunc(PADName PadName, PadFunc padFunc)
{
    PADFUNC->PAD[PadName] = padFunc;
}

void PAD_XIOMUX(PADName PadName, XIOFuncSel ioFunc)
{
    PADFUNC->PAD[PadName] = ioFunc << 8 | PADFUNC6;
    IOFUNC->XIO[ioFunc] = PadName;
}